package com.waves.task.strategy.receive;

import com.waves.core.frequencycontrol.enums.BusinessErrorEnum;
import com.waves.core.utils.AssertUtil;

import java.util.HashMap;
import java.util.Map;

public class ReceiveFactory {
    private static final Map<Integer, AbstractReceiveStrategy> RECEIVE_MAP = new HashMap<>();

    public static void register(Integer type, AbstractReceiveStrategy strategy) {
        RECEIVE_MAP.put(type, strategy);
    }

    public static AbstractReceiveStrategy getStrategy(Integer type) {
        AbstractReceiveStrategy strategy = RECEIVE_MAP.get(type);
        AssertUtil.isNotEmpty(strategy, BusinessErrorEnum.RECEIVE_ERROR.getMsg());
        return strategy;
    }

}
